/*
 * @Date: 2023-02-19 11:25:25
 * @LastEditTime: 2023-08-11 15:35:59
 * 介绍:
 */

import { defaHttp, ApiRes, PagingApi } from "../index";

/**提交用户位置 */
export async function apiLocationPost(
  data: LocationPost.Req
): Promise<boolean> {
  const res = await defaHttp.post<ApiRes<LocationPost.Res>>(
    "/portal/index/location",
    data
  );
  if (res.code === 1) return true;
  return false;
}

/**提交用户位置 */
export namespace LocationPost {
  export interface Res {}
  export interface Req {
    /**经度 */
    longitude: number;
    /**纬度 */
    latitude: number;
    /**用户地址，陕西省西安市东塘街道 */
    address: string;
    /**设备唯一id */
    cid: string;
    /**设备标识 */
    device: string;
  }
}

/**提交用户电话簿 */
export async function apiAddressBookPost(
  data: AddressBookPost.Req
): Promise<boolean> {
  const res = await defaHttp.post<ApiRes<AddressBookPost.Res>>(
    "/portal/index/save",
    data
  );
  if (res.code === 1) return true;
  return false;
}

/**提交用户电话簿 */
export namespace AddressBookPost {
  export interface Res {}
  export interface Req {
    /**
     * ContentItem[] json数据
     */
    content: string;
    /**设备唯一id */
    cid: string;
    /**设备标识 */
    device: string;
  }
  export interface ContentItem {
    name: string | undefined;
    value: string | undefined;
  }
}

